// 当前这个模块，API进行统一管理
import request from "./request";
import mockRequest from './mockServe'

//三级联动接口函数封装 
// /api/product/getBaseCategoryList
export const reqCategoryList = () => {
  //发请求:axios发请求返回的是promise对象
    return  request({ url: '/product/getBaseCategoryList', method: 'GET' });  
};

//获取轮播图mock数据
export const reqGetBannerList = () => mockRequest.get('/banner');

//获取底部floor的mock数据
export const reqFloorList = () => mockRequest.get('/floor');

//获取搜索模块的数据,地址：/api/list，请求方式是：post
// {
//   "category3Id": "61",
//   "categoryName": "手机",
//   "keyword": "小米",
//   "order": "1:desc",
//   "pageNo": 1,
//   "pageSize": 10,
//   "props": ["1:1700-2799:价格", "2:6.65-6.74英寸:屏幕尺寸"],
//   "trademark": "4:小米"
// }
export const reqGetSearchInfo = (params = {}) => request({ url: "/list", method: "POST", data: params, });//必须携带默认参数，两种写法，(a={}) // params||{}

//获取产品详情
export const reqGoodInfo = (skuId) => request({ url: `/item/${skuId}`, method: "GET"});

//添加或更新购物车产品
export const reqAddOrUpdateShopCart = (skuId, skuNum) => request({ url: `/cart/addToCart/${skuId}/${skuNum}`, method: "POST" });

//获取购物车列表信息
export const reqCartList = () => request({ url: '/cart/cartList', method: "GET" })

//删除产品购物车信息
export const reqDeleteCartById = (skuId) => request({ url: `/cart/deleteCart/${skuId}`, method: "DELETE" });

//修改产品状态
export const reqUpdateCheckedById = (skuId, isChecked) => request({ url: `/cart/checkCart/${skuId}/${isChecked}`, method: "GET" });

//获取验证码
export const reqGetCode = (phone) => request({ url: `/user/passport/sendCode/${phone}`, method: "GET" });

//注册用户
export const reqUserRegister = (data) => request({ url: '/user/passport/register', data, method: 'POST' });

//登录接口==>获取token
export const reqUserLogin = (data) => request({ url: '/user/passport/login', data, method: "POST" });

//获取用户信息//虚无带参token 请求头即可
export const reqUserInfo = () => request({ url: '/user/passport/auth/getUserInfo', method: 'GET' });

//退出登录
export const reqLogout = () => request({ url: '/user/passport/logout', method: 'GET' })

//获取用户地址信息
export const reqAddressInfo = () => request({ url: '/user/userAddress/auth/findUserAddressList', method: 'GET' });

//获取订单信息
export const reqOrderInfo = () => request({ url: '/order/auth/trade', method: 'GET' })

//提交订单
export const reqSubmitOrder = (tradeNo, data) => request({ url: `/order/auth/submitOrder?tradeNo=${tradeNo}`, data, method: 'POST' })

//获取支付信息
export const reqPayInfo = (orderId) => request({ url: `/payment/weixin/createNative/${orderId}`, method: 'GET' })

//获取支付状态
export const reqPayStatus = (orderId) => request({ url: `/payment/weixin/queryPayStatus/${orderId}`, method: 'GET' });

//获取个人中心的数据
export const reqMyOrderList = (page, limit) => request({url:`/order/auth/${page}/${limit}`,method:"GET"})